<template>
    <div class="myApproving view-body">
      <table class="layui-table">
        <thead>
        <tr>
          <th>订单号</th>
          <th>用户名</th>
          <th>手机号</th>
          <th>贷款次数</th>
          <th>贷款金额</th>
          <th>申请时间</th>
          <th>来源</th>
          <th>审批人</th>
          <th>审批时间</th>
          <th>订单状态</th>
          <th>详情</th>
        </tr>
        </thead>
        <!--订单表格-->
        <tr v-for="row in tableList">
          <td>{{row.orderNo}}</td>
          <td>{{row.userName}}</td>
          <td>{{row.userPhone}}</td>
          <td>{{row.loanNum}}</td>
          <td>{{row.amount}}</td>
          <td>{{row.borrowTime|formatDate}}</td>
          <td>{{sourceType[row.orderSource]}}</td>
          <td>{{row.approvalName}}</td>
          <td>{{row.approvalTime|formatDate}}</td>
          <td>{{orderType[row.status]}}</td>
          <td><button @click="_getUserMsg(row.id)">详情</button></td>
        </tr>
      </table>
    </div>
</template>

<script>
    import axios from 'axios'
    import {getStorage} from '../../../common/js/localStorage'
    import {formatDate} from "../../../common/js/dateFormate";
    import global from '../../global'
    export default {
      name: "myApproving",
      created(){
        this._getUserList()
      },
      data(){
        return{
          tableList:[],//表格数据 @用于表格渲染
          sourceType:['安卓','ios','微信'],//订单来源状态
          orderType:['全部','待审核','已通过','已拒绝','审核待定']//订单状态类型
        }
      },
      methods:{
        _getUserList(){
          let _this = this
          axios.post('http://'+global.$host+'/loanApply/loanListForPerson',
            {
              search_EQ_order_status:'', //订单状态 0-全部 1-待审核 2-已通过 3-已拒绝 4审核待定
              search_EQ_user_id:'',      //用户ID
              page:'',                   //当前页 默认1
              length:''                  //页长度 默认10

            },
            {
              headers: {
                'Authorization': getStorage('token')
              }
            }
          )
            .then(res => {
              if(res.status===global.ERR_OK){
                if(res.data.status===global.CUSTOM_ERR_OK){
                  let rows = res.data.data.rows
                  _this.tableList = rows
                }
              }else {
                return
              }
            })
            .catch(e => {
              console.log(e)
            })
        }
      },
      filters:{
        formatDate(time){
          if(!time){
            return ''
          }
          let date = new Date(time);
          return formatDate(date,'yyyy-MM-dd hh:mm')
        }
      },
    }
</script>

<style scoped>

</style>
